import request from '@/utils/request'

// 获取应用列表
export function getAppList(query) {
  return request({
    url: '/customer/vAppDetail/list',
    method: 'get',
    params: query
  })
}

// 获取应用详细信息
export function getAppDetail(appId) {
  return request({
    url: '/customer/vAppDetail/' + appId,
    method: 'get'
  })
}

// 新增应用
export function createApp(data) {
  return request({
    url: '/customer/appManage',
    method: 'post',
    data: data
  })
}

// 修改应用
export function updateApp(data) {
  return request({
    url: '/customer/appManage',
    method: 'put',
    data: data
  })
}

// 删除应用
export function deleteApp(appId) {
  return request({
    url: '/customer/appManage/' + appId,
    method: 'delete'
  })
}

// 批量删除应用
export function batchDeleteApps(appIds) {
  return request({
    url: '/customer/appManage/' + appIds.join(','),
    method: 'delete'
  })
}

// 重新生成应用密钥
export function regenerateAppKey(appId) {
  return request({
    url: '/customer/appManage/regenerateKey/' + appId,
    method: 'put'
  })
}

// 获取应用统计信息
export function getAppStats() {
  return request({
    url: '/customer/dashboard/stats',
    method: 'get'
  })
}

// 默认导出对象
const appAPI = {
  getAppList,
  getAppDetail,
  createApp,
  updateApp,
  deleteApp,
  batchDeleteApps,
  regenerateAppKey,
  getAppStats
}

export default appAPI